<template>
  <div>
    <el-form 
      label-width="100px"
      label-position="top"
      class="enterpriseForm"
      :model="webimSetData"
      ref="webimSetData">
      <el-form-item :label="$t('configLazyLoad.webimClient.titleTips6other')" prop="sdkTypeNoticeFlag">
        <el-radio-group v-model="webimSetData.sdkTypeNoticeFlag">
          <el-radio :label="true">{{ $t('config.business.enabeld') }}</el-radio>
          <el-radio :label="false">{{ $t('config.business.disable') }}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" class="primary_btn fr" @click="saveFun">{{$t('public.save')}}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
/**
 * 移动APP客服访客输入状态提示
 */
export default {
  name: 'appTypeNotice',
  data () {
    return {
      webimSetData: {
        sdkTypeNoticeFlag: false
      }
    }
  },
  methods: {
    saveFun () {
      this.$refs.webimSetData.validate((valid) => {
        if (valid) {
          this.$store.dispatch('saveGlobalSet', this.webimSetData).then((rep) => {
            if (rep.success) {
              this.$message.success(this.$t('config.channel.configSuccess'))
            } else {
              this.$message.error(this.$t('qualityCheck.saveFali'))
            }
          })
        }
      })
    }
  },
  beforeMount () {
    this.$store.dispatch('getGlobalSetById', {}).then((resp) => {
      if (resp.success && resp.row) {
        this.webimSetData._id = resp.row._id
        this.webimSetData.sdkTypeNoticeFlag = resp.row.sdkTypeNoticeFlag || false
      }
    })
  }
}
</script>
<style lang="stylus" scoped>
  @import "../../../../../assets/common.styl"
    .enterpriseForm
      width 500px
      .title
        font-weight 900
        margin-bottom 5px
      .remark
        color: #888888
        font-size 12px
        margin-top 10px
</style>